<template>
   <el-card class="box-card">
    <div slot="header" class="clearfix">
    <h1 class="container-title fl">添加标签</h1>
    </div>
    <!-- 在这里写数据 -->
    <el-card class="box-card-min">
    <div slot="header" class="clearfix">
        <!-- 标签id -->
  <el-form status-icon   label-width="80px" class="demo-ruleForm">
   <el-form-item label="标签id">
    <el-input type="text" v-model="tagname" autocomplete="off" style="width:250px;" disabled></el-input>
  </el-form-item>
   <el-form-item label="货物类型">
    <el-select  v-model="tid" style="width:250px;">
     <el-option  v-for="role in tableData" :label="role.goodname" :key="role.id" :value="role.id"></el-option>
    </el-select>
  </el-form-item>
  
  
  <el-form-item label="分配用户">
    <el-select  v-model="uid" style="width:250px;">
     <el-option  v-for="role in role_list" :label="role.username" :key="role.id" :value="role.id"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="updatetag" style="width:250px;">修改</el-button>
  </el-form-item>
</el-form>
</div>
</el-card>
</el-card>
       
    </template>
    
    <script>
      import {adduser,role,showgt,showu,ctag,onetag,uptag} from '../api/api'
    
        export default {
    
            data(){
                return {
                    msg:'你好，这里是首页',
                    tagname:'',
                    tid:'',
                    uid:'',
                    
                    role_list:[],
                    tableData:[]
                        
                }
            },
            //定义组建标签
            components:{
            },
            filters: {
     
　　},
            //自定义方法
            methods:{
                  show_gt(){
                  showgt().then( res => {
                  this.tableData=res
         
              })
              }, 
              show_user(){
                showu().then( res => {
                  this.role_list=res
         
              })
    
          },
          updatetag:function(){
            var id=localStorage.getItem('tag_id')
            var params={'id':id,'tid':this.tid,'uid':this.uid}
            uptag(params).then( res => {
                  this.$Message(res.message)
         
              })
          }
    
            },
            //钩子方法
            mounted:function(){
                var receiveValue = this.$route.params.value
                this.show_gt();
                this.show_user();
                var params={'id':receiveValue}
                onetag(params).then( res => {
                  this.tagname=res[0]['tagname']
                  localStorage.setItem('tag_id',res[0]['id'])
         
              })
    
            },
            //监听属性
            watch:{
    
    
            },
            //计算属性
            computed:{
    
    
            }
    
    
    
        }
    
    
    </script>
    
    <style>
 .box-card-min{
    height:250px;
    width:450px;
 
    margin:0 auto;
    margin-top:30px;
    
 }
  .box-card{
        
         height:650px;

    }
    
  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }
  .container-title {
    font-size: 20px;
    line-height: 32px;
    font-weight: normal;
    color: #39486c;
  }
  .fl {
    float: left;
  }
  .inp-box {
    font-size: 16px;
    line-height: 32px;
    margin-left: 30px;
}
 
 
  .login_title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }
    </style>